﻿/*
 * Microsoft .NET  2.0+ version of Sphinx searchd client (Sphinx API)
 * 
 * Copyright (c) 2009, Shaun Berryman
 * All rights reserved
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License. You should have
 * received a copy of the GPL license along with this program; if you
 * did not, you can find it at http://www.gnu.org/
 */

using System;
using System.Collections.Generic;
using System.Text;

using SphinxSearchApi.Extension;

namespace SphinxSearchApi
{
    public class AnchorPoint
    {
        /// <summary>
        /// Name of the attribute that contains the latitude
        /// </summary>
        public string AttributeLatitude { get; set; }

        /// <summary>
        /// Name of the attribute that contains the longitude
        /// </summary>
        public string AttributeLongitude { get; set; }

        /// <summary>
        /// Latitude anchor point (in radians)
        /// </summary>
        public double Latitude { get; set; }

        /// <summary>
        /// Longitude anchor point (in radians)
        /// </double>
        public double Longitude { get; set; }

        /// <summary>
        /// Latitude in degrees. Converts the Latitude property to/from radians
        /// </summary>
        public double LatitudeDegrees
        {
            get
            {
                return Latitude.ToDegrees();
            }
            set
            {
                if (value < -90 || value >= 91)
                    throw new ArgumentOutOfRangeException(
                        "LatitudeDegrees", 
                        value, 
                        "Invalid latitude, latitude angles can range up to +90 degrees (North) or -90 degrees (South).");

                Latitude = value.ToRadians();
            }
        }

        /// <summary>
        /// Longitude in degrees. Converts the Longitude property to/from radians
        /// </summary>
        public double LongitudeDegrees
        {
            get
            {
                return Longitude.ToDegrees();
            }
            set
            {
                if (value < -180 || value >= 181)
                    throw new ArgumentOutOfRangeException(
                        "LongitudeDegrees", 
                        value, 
                        "Invalid longitude, longitude angles can range up to +180 degrees (East) or -180 degrees (West).");

                Longitude = value.ToRadians();
            }
        }
    }
}
